package com.yhj.handler;

import org.springframework.core.annotation.Order;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author yaohj
 * @date 2024年11月21日 16:01
 * @Description: 本来是想给controller加注解@Validated，可能不能在运行时加注解
 */
@Order(0)
@RestControllerAdvice
@Validated
public class GlobalValidationHandler {

    //或者直接引用下面的类
 /*   @Aspect
    @Component
    public class ValidationAspect {

        @Pointcut("within(@org.springframework.stereotype.Controller *) || " +
                "within(@org.springframework.web.bind.annotation.RestController *)")
        public void controllerPointcut() {
            // Pointcut definition here
        }

        @Around("controllerPointcut()")
        public Object validate(ProceedingJoinPoint joinPoint) throws Throwable {
            // Before method execution logic (if any)
            Object result = joinPoint.proceed();
            // After method execution logic (if any)
            return result;
        }
    }*/
}
